#include "DocStats.h"
#include <iostream>
#include <stdexcept>
#include "Paragraph.h"
#include "RasterBitmap.h"
#include "VectorGraphics.h"

DocStats::DocStats() : chars_(0), images_(0), graphs_(0)
{
}


void DocStats::Visit(Paragraph& elem)
{
	std::cout << "Visit Paragraph" << std::endl;
	chars_ += elem.getChars();
}
void DocStats::Visit(RasterBitmap& elem)
{
	std::cout << "Visit RasterBitmap" << std::endl;
	images_ += 1;
}

void DocStats::Visit(VectorGraphics&)
{
	graphs_ += 1;
}

void DocStats::Visit(DocElement&)
{
	throw std::runtime_error("Unable to match a concrete type of DocElement!");
}


void DocStats::Display() 
{
	std::cout << "chars: " << chars_ << std::endl;
	std::cout << "images: " << images_ << std::endl;
	std::cout << "graphs: " << graphs_ << std::endl;
}
